package com.doge.controller.wx;

import com.doge.bean.base.BaseData;
import com.doge.bean.base.BaseParam;
import com.doge.bean.base.BaseRespVo;
import com.doge.bean.vo.goods.GoodsDetailVO;
import com.doge.bean.vo.wxgoods.WxGoodsCategoryVO;
import com.doge.bean.vo.wxgoods.WxGoodsDetailVO;
import com.doge.bean.vo.wxgoods.WxGoodsListVo;
import com.doge.service.wx.goods.WxGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: project2-wechat-mall
 * @description:
 * @author: 305905917@qq.com
 * @create: 2021-12-02 17:47
 **/
@RestController
@RequestMapping("wx/goods")
public class WxGoodsController {
    @Autowired
    WxGoodsService wxGoodsService;

    //查询所有商品数量
    @RequestMapping("count")
    public BaseRespVo count() {
        long count = wxGoodsService.count();
        return BaseRespVo.ok(count);
    }

    //根据id查询相应的类目
    @RequestMapping("list")
    public BaseRespVo list(Integer categoryId, Integer page, Integer limit,String keyword,String sort,String order) {
        WxGoodsListVo wxGoodsListVo = wxGoodsService.list(categoryId, page, limit,keyword,sort,order);
        return BaseRespVo.ok(wxGoodsListVo);
    }


    //根据类目id返回兄弟类目
    @RequestMapping("category")
    public BaseRespVo category(Integer id) {
        WxGoodsCategoryVO wxGoodsCategoryVOS = wxGoodsService.category(id);
        return BaseRespVo.ok(wxGoodsCategoryVOS);
    }

    //显示相关的商品
    @RequestMapping("related")
    public BaseRespVo related(Integer id) {
        BaseData baseData = wxGoodsService.related(id);
        return BaseRespVo.ok(baseData);
    }


    //显示商品的详细信息
    @RequestMapping("detail")
    public BaseRespVo detail(Integer id) {

        WxGoodsDetailVO wxGoodsDetailVO = wxGoodsService.detail(id);

        return BaseRespVo.ok(wxGoodsDetailVO);
    }
}
